<style>
.login {
  width: 500px;
  text-align: center;
  margin: 0 auto;
  /* padding-top: 40px; */
  top: 100px;
  border: 1px solid #eee;
  padding-bottom: 70px;
  background-color: #fff;
  position: relative;
  left: 300px;
  border-radius: 10px;
}

.tag {
  display: flex;
  width: 50px;
  margin-left: 100px;
  margin-top: 30px;
}

.img {
  background-image: url('/src/img/qi.jpg');
  height: 100vh;
  position: relative;
  background-size: 100% 100%;
  overflow-y: hidden;
  text-align: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
</style>



<template>
  <div class="img">



    <div class="login">

      <div>
        <h2>Log in</h2>
      </div>
      <div>
        <el-tag class="tag">账号</el-tag>
        <el-input prefix-icon="el-icon-user" maxlength="11" style="width: 300px;" v-model="account"
          placeholder="请输入账号"></el-input>
      </div>
      <div>
        <el-tag class="tag">密码</el-tag>
        <el-input prefix-icon="el-icon-lock" style="width: 300px;" placeholder="请输入密码" v-model="password"
          show-password></el-input>
      </div>
      <div>
        <el-button @click="login" type="primary" style="width: 300px; margin-top: 20px;" plain>登录</el-button>

      </div>
    </div>
  </div>

</template>


<script>

import { close_loading, open_loading } from "@/utils/message";
import { logins } from '@/api/login';
import { set_token } from '@/utils/auth';




export default {
  data: () => {
    return {
      account: '15570820928',
      password: '123456'
    }
  },
  methods: {

    async login() {
      open_loading("登录中...")
      close_loading();
      const res = await logins({
                account: this.account,
                password: this.password
      });
      
      close_loading();
            if (res.code === 0) {
                set_token(res.data);
                this.$router.push('/');
                // location.href = '/';
            } else {
                this.$message.error(res.message);
            }
    


      // axios.post('http://localhost:47166/api/Login/Logins', {
      //   account: this.account,
      //   password: this.password
      // }).then(function (res) {
      //   open_loading("登录中...")

      //   close_loading();
      //   if (res.code === 0) {
      //     set_token(res.data);
      //     alert("11111")
      //     this.$router.push('/');

      //   } else {

      //     //this.$message.error(res.message);
      //   }

      // })


      //   open_loading("登录中...")
      // const res = await logins({
      //   account :this.account,
      //   password:this.password
      // });
      // close_loading();
      // if (res.code===0) {
      //   set_token(res.data);
      //   this.$router.push('/');
      // }else{
      //   this.$message.error(res.message);
      // }
    }

  },
  components: {

  }
}

</script>